<?php
	/**
	* @author living
	* @desc 
	**/
class CategoryController extends AppController {
	var $name = 'Category';

	var $uses = array (
		'JobCountTmp',
		'ViewJobStatusCount',
		'SysParams',
		'Job',
		'JobArea',
		'JobCategory',
		'JobAttentionArea',
		'JobAttentionThema',
		'JobPickupThema',
		'JobPickupArea',
		'Company'
	);

	/**
	* @author zhouguoyan
	* @desc 首页地域和tema的内页 $area为SysParams.description的值
	**/
	function index() {
//		ini_set('max_execution_time', '0');
//		$title = $this->SysParams->find("SysParams.deleted is null" .
//									" AND SysParams.kbn=''	");
//		$this->pageTitle=$title;
/*		$area_info = $this->SysParams->getArea();
		$tema_info = $this->SysParams->getTema();
		$this->set('area_info', $area_info);
		$this->set('tema_info', $tema_info);
		
		$area_id = $this->SysParams->getAttentionId($area);
		$tema_id = $this->SysParams->getTemaId($area);
		
		if(empty($area_id)&&empty($tema_id)){
			$this->show404();
		}
		
		if(!empty($area_id)){
			$id = $area_id['SysParams']['id'];
			$this->pageTitle=$area_id['SysParams']['title'];
			
			$re = $this->JobAttentionArea->findAll("\"JobAttentionArea\".\"area_id\"= '".$id."' And \"JobAttentionArea\".\"deleted\" is null");
			$Attention_info_id = '';
			foreach ($re as $index => $list) {
				$Attention_info_id .= $list['JobAttentionArea']['job_id'] . ',';
			}
			$Attention_info_id = substr($Attention_info_id, 0, -1);
			
			$re = $this->JobPickupArea->findAll("\"JobPickupArea\".\"area_id\"= '".$id."' And \"JobPickupArea\".\"deleted\" is null ");
			$pick_info_id = '';
			foreach ($re as $index => $list) {
				$pick_info_id .= $list['JobPickupArea']['job_id'] . ',';
			}
			$pick_info_id = substr($pick_info_id, 0, -1);
			
			$re = $this->JobArea->findAll("\"JobArea\".\"job_area_id\"= '".$id."' And \"JobArea\".\"deleted\" is null ");
			$sample_info_id = '';
			foreach ($re as $index => $list) {
				$sample_info_id .= $list['JobArea']['job_id'] . ',';
			}
			$sample_info_id = substr($sample_info_id, 0, -1);
		}
		elseif (!empty($tema_id)){
			$id = $tema_id['SysParams']['id'];
			$this->pageTitle=$tema_id['SysParams']['title'];
			
			$re = $this->JobAttentionThema->findAll("\"JobAttentionThema\".\"tema_id\"= '".$id."' And \"JobAttentionThema\".\"deleted\" is null ");
			$Attention_info_id = '';
			foreach ($re as $index => $list) {
				$Attention_info_id .= $list['JobAttentionThema']['job_id'] . ',';
			}
			$Attention_info_id = substr($Attention_info_id, 0, -1);
			
			$re = $this->JobPickupThema->findAll("\"JobPickupThema\".\"tema_id\"= '".$id."' And \"JobPickupThema\".\"deleted\" is null ");
			$pick_info_id = '';
			foreach ($re as $index => $list) {
				$pick_info_id .= $list['JobPickupThema']['job_id'] . ',';
			}
			$pick_info_id = substr($pick_info_id, 0, -1);
			
			$re = $this->JobCategory->findAll("\"JobCategory\".\"category_id\"= '".$id."' And \"JobCategory\".\"deleted\" is null ");
			$sample_info_id = '';
			foreach ($re as $index => $list) {
				$sample_info_id .= $list['JobCategory']['job_id'] . ',';
			}
			$sample_info_id = substr($sample_info_id, 0, -1);
		}
		
		
		
		$this->_setAttentionData($Attention_info_id);
		$this->_setPickupData($pick_info_id);
		$this->_setJobData($Attention_info_id,$pick_info_id,$sample_info_id,$area);
		$this->set('area', $area);
		if($this->page>1){
			$this->set('area_page','1');
			$this->set('tema_page','1');
			$this->set('attention_page','1');
		}
		$this->set('area_id', $area_id);
		$this->set('tema_id', $tema_id);
		
		if(!empty($area_id)){
			$this->set('Area_img',$area);
		}
		else{
			$this->set('Tema_img',$area);
		}
*/		
		$this->render('index');
		
		
	}
	
	
	/**
	* @author zhouguoyan
	* @desc 查找Attention的信息
	**/	
	function _setAttentionData($Attention_info_id){
		$attention_info = array();
		if(!empty($Attention_info_id)){
			$params['Attention_info_id']=$Attention_info_id;
			$attention_info = $this->Job->getAreaAttentionJob($this->Search,$params);
		}
		//lfx add 2013-09-27 update attention_url start
		$tmp_data = $attention_info;
		foreach($tmp_data as $k => &  $list){
			$list['Job']['attention_note']=$this->Common->relative_path_set($list['Job']['attention_note']);
			if (!empty($list['Job']['attention_url'])){
			$list['Job']['attention_url'] = 'attention_url/'.$list['Job']['attention_url'];
			$list['Job']['attention_url']=$this->Common->relative_path_set($list['Job']['attention_url']);
			}
		}
		
		$attention_info = $tmp_data;
		unset($tmp_data);
		//lfx add 2013-09-27 update attention_url end		
		
		$this->set('attention_info', $attention_info);	
	}
	
	function _setPickupData($Pickup_info_id) {
		$pickup_info = array();
		if(!empty($Pickup_info_id)){
			$params['Attention_info_id']=$Pickup_info_id;
			$pickup_info = $this->Job->getAreaPickUpJob($this->Search,$params);
		}
		$this->Output->htmlspecialchars_decode($pickup_info);		
		$this->set('pickup_info', $pickup_info);
	}
	
	/**
	* @author zhouguoyan
	* @desc 查找pickup的信息
	**/		
	function _setJobData($Attention_info_id,$pick_info_id,$sample_info_id,$area){
		$params['Attention_info_id']=$Attention_info_id;
		$params['pick_info_id']=$pick_info_id;
		if(!empty($sample_info_id)){
			$params['sample_info_id']=$sample_info_id;
		}else{
			$params['sample_info_id']=-1;
		}
		$sample_info = $this->Job->getAreaSampleJob($this->Search,$params,$this->show,$this->page);
		$count=$this->Job->getAreaSampleJobCount($this->Search,$params);
        $pagestr=$this->initPageCount($count,'件','件','中',$this->show);
        $this->set('pagestr',$pagestr);
        
        $this->Output->htmlspecialchars_decode($sample_info);
		$this->set('sample_info', $sample_info);
		$this->setPaging('ajax','/'.$area,$count,$this->show,null,$this->show);
	}

}
?>